package com.qingke.oms.command.user;

import java.util.List;

import com.qingke.oms.command.UserCommand;
import com.qingke.oms.pojo.Shop;
import com.qingke.oms.pojo.User;
import com.qingke.oms.util.OMSConsole;

public class ListAllShopCommand extends UserCommand {

	public ListAllShopCommand(User user) {
		super(user);
	}

	@Override
	public void execute() {
		List<Shop> list=dao.selectAllShop();
		if(list.size()==0){
			OMSConsole.println("There is no shop now.");
			return ;
		}
		OMSConsole.println("-------all shop-------");
		for(Shop s:list){
			User u=dao.selectUserById(s.getOwnerId());
			String str="[id]:"+s.getId()+",[owner]:"+u.getName()+",[name]:"+s.getName();
			if(!s.getDescription().equals(""))
				str+=",[descroption]:"+s.getDescription();
			OMSConsole.println(str);
		}
		OMSConsole.println();
	}

}
